package com.welink.cmp.adapter.api.metadata.query;

import com.welink.cmp.dto.metadata.MetadataIdListQry;
import com.welink.cmp.dto.metadata.MetadataIdQry;
import com.welink.cmp.dto.metadata.firewall.clientobject.FirewallCO;
import com.welink.cmp.dto.metadata.firewall.query.FirewallListByPageQry;
import com.welink.cmp.meatdata.service.FirewallAppService;
import com.welink.common.dto.MultiResponse;
import com.welink.common.dto.PageResponse;
import com.welink.common.dto.SingleResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 防火墙查询服务API
 * @author yanwei li create  2024-05-22 11:20
 */
@RestController("/api/firewall/query")
public class FirewallQueryServiceApi {

    @Autowired
    private FirewallAppService firewallAppService;

    /**
     * [ID查询]查询防火墙信息详情
     * @param idQry 主键ID
     * @return Firewall DTO
     */
    @GetMapping("/fw-item")
    public SingleResponse<FirewallCO> queryFwById(@RequestBody MetadataIdQry idQry){
        FirewallCO dto = firewallAppService.getFirewallById(idQry.getId());
        return SingleResponse.of(dto);
    }


    /**
     * [列表查询]列表查询防火墙信息
     * @param listQuery id list
     * @return 防火墙列表
     */
    @GetMapping("/fw-list")
    public MultiResponse<FirewallCO> listQueryFirewall(@RequestBody MetadataIdListQry listQuery){
        List<FirewallCO> list = firewallAppService.hostListQuery(listQuery);
        return MultiResponse.of(list);
    }


    /**
     * [分页查询]分页查询防火墙信息
     * @param pageQry
     * @return
     */
    @GetMapping("/fw-page")
    public PageResponse<FirewallCO> pageQueryFirewall(@RequestBody FirewallListByPageQry pageQry){
        final PageResponse<FirewallCO> firewallCOPageResponse = firewallAppService.firewallPageQuery(pageQry);
        return firewallCOPageResponse;
    }


}
